package de.jmda.gen.java.impl;

import java.util.LinkedList;
import java.util.List;

import de.jmda.gen.Generator;
import de.jmda.gen.java.FieldModifiersGenerator;
import de.jmda.gen.java.ModifiersUtil;

/**
 * @author roger.jmda@gmail.com
 */
public class DefaultFieldModifiersGenerator
    extends AbstractModifiersGenerator implements FieldModifiersGenerator
{
	public final static Generator PUBLIC    = dg(ModifiersUtil.PUBLIC);

	public final static Generator PROTECTED = dg(ModifiersUtil.PROTECTED);
	public final static Generator PRIVATE   = dg(ModifiersUtil.PRIVATE);
	public final static Generator FINAL     = dg(ModifiersUtil.FINAL);
	public final static Generator STATIC    = dg(ModifiersUtil.STATIC);
	public final static Generator TRANSIENT = dg(ModifiersUtil.TRANSIENT);
	public final static Generator VOLATILE  = dg(ModifiersUtil.VOLATILE);

	private boolean bPublic    = false;
	private boolean bProtected = false;
	private boolean bPrivate   = false;
	private boolean bFinal     = false;
	private boolean bStatic    = false;
	private boolean bTransient = false;
	private boolean bVolatile  = false;
	
	@Override
  public List<Generator> getGeneratorComponents()
  {
		List<Generator> result = new LinkedList<Generator>();
		
		if (bPublic   ) { result.add(PUBLIC); }
		if (bProtected) { result.add(PROTECTED); }
		if (bPrivate  ) { result.add(PRIVATE); }
		if (bFinal    ) { result.add(FINAL); }
		if (bStatic   ) { result.add(STATIC); }
		if (bTransient) { result.add(TRANSIENT); }
		if (bVolatile ) { result.add(VOLATILE); }

		return result;
  }

	public boolean isPublic()
  {
  	return bPublic;
  }

	public void setPublic(boolean bPublic)
  {
  	this.bPublic = bPublic;

  	if (bPublic)
  	{
  		setPrivate(false);
  		setProtected(false);
  	}
  }

	public boolean isProtected()
  {
  	return bProtected;
  }

	public void setProtected(boolean bProtected)
  {
  	this.bProtected = bProtected;

  	if (bProtected)
  	{
  		setPublic(false);
  		setPrivate(false);
  	}
  }

	public boolean isPrivate()
  {
  	return bPrivate;
  }

	public void setPrivate(boolean bPrivate)
  {
  	this.bPrivate = bPrivate;

  	if (bPrivate)
  	{
  		setPublic(false);
  		setProtected(false);
  	}
  }

	public boolean isFinal()
  {
  	return bFinal;
  }

	public void setFinal(boolean bFinal)
  {
  	this.bFinal = bFinal;
  }

	public boolean isStatic()
  {
  	return bStatic;
  }

	public void setStatic(boolean bStatic)
  {
  	this.bStatic = bStatic;
  }

	public boolean isTransient()
  {
  	return bTransient;
  }

	public void setTransient(boolean bTransient)
  {
  	this.bTransient = bTransient;
  }

	public boolean isVolatile()
  {
  	return bVolatile;
  }

	public void setVolatile(boolean bVolatile)
  {
  	this.bVolatile = bVolatile;
  }
}